//对api进行同一管理
// import axios from "axios";
import requests from "./request";

//三级联动接口
///api/product/getBaseCategoryList  GET  无参数
export const reqCategoryList=()=>{
    return requests({
            url:'/product/getBaseCategoryList',
            method:'get'
        })   
}
//搜索商品接口
///apic   POST  10个参数
// 需要参数
export const reqGetSearchList=(params)=>{
    return requests({
        url:"/list",
        method:"post",
        data:params
    })
}
//商品详情接口
///api/item/{ skuId }    GET    参数：skuId（必须有） 
export const reqGetGoodDetail=(skuId)=>{
    return requests({
        url:`/item/${skuId}`,
        // 不能用以下的data形式
        // url:"/item",
        method:'get',
        // data:skuId
    })
}
//添加购物车物品   也可以修改商品数量
//  /api/cart/addToCart/{ skuId }/{ skuNum }     POST     
export const reqGetAddShopping=(skuId,skuNum)=>{
    return requests({
        url:`/cart/addToCart/${skuId}/${skuNum}`,
        method:"post"
    })
}
//获取购物车列表内容
///api/cart/cartList    get    无参数
export const reqGetShopCartList=()=>{
    return requests({
        url:"/cart/cartList",
        method:"get"
    })
}

//删除选中内容
////api/cart/deleteCart/{skuId}  delete 
export const reqDelCheckGood=(skuId)=>{
    //按理说return后可以使用大括号进行多个内容的返回是我弄错了吗
    return requests({
        url:`/cart/deleteCart/${skuId}`,
        method:"delete"
    })
}
//切换商品选中状态
/////api/cart/checkCart/{skuId}/{isChecked}    get 
export const reqcutGoodCheckedStatus=(skuId,isChecked)=>{
    return requests({
        url:`/cart/checkCart/${skuId}/${isChecked}`,
        method:"get"
    })
}
//注册用户
////api/user/passport/register     POST   phone password code nickName
export const reqRegisterUser=(params)=>{
    return requests({
        url:"/user/passport/register",
        method:"post",
        data:params
    })
}
////获取注册验证码 
/////api/user/passport/sendCode/phone  get   phone
export function reqRegisterCode(phone){
    return requests({
        url:`/user/passport/sendCode/${phone}`,
        method:"get",
    })
}
//登录接口
/////api/user/passport/login   post     phone   password
export const reqLogin=(data)=>{
    return requests({
        url:"/user/passport/login",
        method:"post",
        data
    })
}
//自动登录（通过token获取用户信息
// /api/user/passport/auth/getUserInfo   get
export const reqUserInfo=()=>{
    return requests({
        url:"/user/passport/auth/getUserInfo",
        method:"get"
    })
}
//退出登录
// /api/user/passport/logout   get
export const reqLoginOut=()=>{
    return requests({
        url:"/user/passport/logout",
        method:"get"
    })
}
//获取订单交易页信息,商品订单
// /api/order/auth/trade  get
export const reqTrade=()=>{
    return requests({
        url:"/order/auth/trade",
        method:"get"
    })
}
///用户地址信息
// /api/user/userAddress/auth/findUserAddressList    get
export const reqUserAddress=()=>{
    return requests({
        url:"/user/userAddress/auth/findUserAddressList",
        method:"get"
    })
}
///提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo}   post
export const reqCommitOrder=(tradeNo,data)=>{
    return requests({
        url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method:"post",
        data
    })
}
///获取支付信息
///api/payment/weixin/createNative/{orderId}  get
export const reqPayInfo=(orderId)=>{
    return requests({
        url:`/payment/weixin/createNative/${orderId}`,
        method:"get"
    })
}
//查询支付状态
////api/payment/weixin/queryPayStatus/{orderId}  get
export const reqPayStatus=(orderId)=>{
    return requests({
        url:`/payment/weixin/queryPayStatus/${orderId}`,
        method:"get"
    })
}
//  获取我的订单列表
// /api/order/auth/{page}/{limit}   get
export const reqOrder=(page,limit)=>{
    return requests({                           
        url:`/order/auth/${page}/${limit}`,
        method:"get"
    })
}

















// export const getList=function reqCategory() {
    
// }
/////////写mock模拟的Ajax请求
//引入mock
import mockRequests from "./mockRequest";
export const getBannerList=()=>{
    return mockRequests({
        url:'/banner',
        method:'get'
    })
}
// export const newBannerList
export const getFloorList=()=>mockRequests.get('/floor')